package cn.com.huzo.repository.purchase.impl;

import cn.com.huzo.model.entities.purchase.PoLinesMrpFeedingLinesEntity;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import cn.com.huzo.repository.purchase.PoLinesMrpFeedingLinesRepository;

/**
 * 采购订单-引入的补料单明细数据访问对象。
 *
 * @author 吴旭
 */
@Repository("PoLinesMrpFeedingLinesRepository")
public class PoLinesMrpFeedingLinesRepositoryImpl extends GenericRepositoryImpl<PoLinesMrpFeedingLinesEntity, String>
        implements PoLinesMrpFeedingLinesRepository {

    private final String namespace = "cn.com.huzo.repository.purchase.PoLinesMrpFeedingLinesRepository";

    /**
     * 构造函数,设置the instance to ProductRepositoryImpl.class.
     */
    public PoLinesMrpFeedingLinesRepositoryImpl() {
        super(PoLinesMrpFeedingLinesEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer fetchForCount(Map<String, Object> filters) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForCount"), filters);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<PoLinesMrpFeedingLinesEntity> fetchForPage(Map<String, Object> filters) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForPage"), filters);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insertLines(Long headerId, Long updatedBy, List<String> mrpFeedingLinesIdList, Short separateFlagByPartOfNeed) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("HeaderId", headerId);
        criterion.put("MrpFeedingLinesIdList", mrpFeedingLinesIdList);
        criterion.put("SeparateFlagByPartOfNeed", separateFlagByPartOfNeed);
        criterion.put("CreatedBy", updatedBy);
        criterion.put("UpdatedBy", updatedBy);

        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insertLines"), criterion);
    }
    
    /**
     * {@inheritDoc}
     */
    @Override
    public Integer deleteInvalidRow(Long headerId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "deleteInvalidRow"), headerId);
    }
}
